# -*- coding: utf-8 -*-
# @Time    : 2024/1/15  18:59
# @Author  : zhanghao
# @FileName: task_req.py
# @Software: PyCharm
"""
    Description: 任务请求model
"""
from pydantic import BaseModel
from typing import Optional

from helper.response_result import ResponseResult


class TaskResponse(BaseModel):

    result: str
    reason: str
    data: Optional[None]

    def setData(self, data):
        self.data = data

    @staticmethod
    def buildFailed():
        response = TaskResponse(result=ResponseResult.description(ResponseResult.FAILED),
                                reason=ResponseResult.desc(ResponseResult.FAILED),
                                data=None)
        return response

    @staticmethod
    def buildFailed(failed_reason):
        response = TaskResponse(result=ResponseResult.description(ResponseResult.FAILED),
                                reason=failed_reason,
                                data=None)
        return response

    @staticmethod
    def buildSuccess():
        response = TaskResponse(result=ResponseResult.description(ResponseResult.SUCCESS),
                                reason=ResponseResult.desc(ResponseResult.SUCCESS),
                                data=None)
        return response

